package com.thanh.icook;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class GridviewAdapter_Week extends BaseAdapter
{
	private ArrayList<String> listNo;
	private ArrayList<String> listDish_Sang;
	private ArrayList<String> listDish_Trua;
	private ArrayList<String> listDish_Chieu;
	private Activity activity;
	public GridviewAdapter_Week(Activity activity,
			ArrayList<String> listNo, 
			ArrayList<String> listDish_Sang,
			ArrayList<String> listDish_Trua,
			ArrayList<String> listDish_Chieu) {
		super();
		this.listNo = listNo;
		this.listDish_Sang = listDish_Sang;
		this.listDish_Trua = listDish_Trua;
		this.listDish_Chieu = listDish_Chieu;
		this.activity = activity;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return listNo.size();
	}

	@Override
	public String getItem(int position) {
		// TODO Auto-generated method stub
		return listNo.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	public static class ViewHolder
	{
		public TextView txtViewNo;
		public TextView txtViewDish_Sang;
		public TextView txtViewDish_Trua;
		public TextView txtViewDish_Chieu;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder view;
		LayoutInflater inflator = activity.getLayoutInflater();
		
		if(convertView==null)
		{
			view = new ViewHolder();
			convertView = inflator.inflate(R.layout.gridviewrow_listdishweek, null);
			
			view.txtViewNo = (TextView) convertView.findViewById(R.id.textView_No);
			view.txtViewDish_Sang = (TextView)convertView.findViewById(R.id.textView_dish_sang);
			view.txtViewDish_Trua = (TextView)convertView.findViewById(R.id.textView_dish_trua);
			view.txtViewDish_Chieu = (TextView)convertView.findViewById(R.id.textView_dish_chieu);
			convertView.setTag(view);
		}
		else
		{
			view = (ViewHolder) convertView.getTag();
		}
		
		view.txtViewNo.setText(listNo.get(position));
		view.txtViewDish_Sang.setText(listDish_Sang.get(position));
		view.txtViewDish_Trua.setText(listDish_Trua.get(position));
		view.txtViewDish_Chieu.setText(listDish_Chieu.get(position));	
		return convertView;
	}

}
